\section{Migrating GM Models to AUTOSAR}
\label{s:gm2autosar}
% 
% We previously presented an industrial transformation that migrates legacy models
% for General Motors (GM) into their equivalent AUTOSAR models~\cite{GMcasestudy}. 
% - proprietary metamodel - the \gmtoautosar transformation
%
Previously, we reported on an industrial transformation that maps between
subsets of a legacy metamodel for General Motors (GM) and the AUTOSAR
metamodel~\cite{GMcasestudy}. This \gmtoautosar transformation manipulated
subsets of the metamodels that represent the deployment and interaction of
software components.  We summarize the source and target metamodels of the
\gmtoautosar transformation
and its implementation in DSLTrans. More details on the source and target
metamodels can be found in~\cite{GMcasestudy}.

\subsubsection{The GM Metamodel.}
Fig.~\ref{fig:gmMMfig} shows the
subset of 
a simplified version of 
the GM metamodel 
manipulated by our transformation
in~\cite{GMcasestudy}. A \emph{PhysicalNode} may contain multiple
\emph{Partition}s (i.e., processing units). Multiple \emph{Module}s can be
deployed on a single \emph{Partition}. A \emph{Module} is an atomic, deployable,
and reusable software element and can contain multiple \emph{ExecFrame}s. An
\emph{ExecFrame}, i.e., an execution frame, is the basic unit for software
scheduling. It contains behavior-encapsulating entities, and is responsible for
providing/requiring \emph{Service}s to/from these behavior-encapsulating
entities.
\begin{figure}[t]
\begin{minipage}[b]{\linewidth}
\centering
  \includegraphics[width=0.8\linewidth]{imgs/GMmm.jpg}\\[-2ex]
\caption{Subset of the source GM metamodel used by our transformation
in~\cite{GMcasestudy}.}
\label{fig:gmMMfig}
\centering
\includegraphics[width=0.95\linewidth]{imgs/AUTOSARmm.jpg}\\[-2ex]
\caption{Subset of the target AUTOSAR metamodel used by our transformation
in~\cite{GMcasestudy}.}
\label{fig:autosarMMfig}
\end{minipage}
% \vspace{-0.3in}
\end{figure}

\subsubsection{The AUTOSAR Metamodel.}
In AUTOSAR, an Electronic Control Unit (ECU) is a physical unit on which
software is deployed. Fig.~\ref{fig:autosarMMfig} shows the subset of the
AUTOSAR metamodel~\cite{systemp} used by our transformation.
In AUTOSAR, the ECU configuration is modeled using a \emph{System} that
aggregates \emph{SoftwareComposition} and \emph{SystemMapping}.
\emph{SoftwareComposition} points to \emph{CompositionType} which eliminates any
nested software components in a \emph{SoftwareComposition}.
\emph{SoftwareComposition} models the architecture of the software components
(i.e., \emph{ComponentPrototype}s) deployed on an ECU and their ports (i.e.,
\emph{PPortPrototype}/ \emph{RPortPrototype} for providing/ requiring data and
services). Each \emph{ComponentPrototype} has a type that refers to its
container \emph{CompositionType}.

\emph{SystemMapping} binds software components to ECUs using
\emph{SwcToEcuMappings}. \emph{SwcToEcuMapping}s assign
\emph{SwcToEcuMapping\_component}s to an \emph{EcuInstance}.
\emph{SwcToEcuMapping\_component}s, in turn, refer to \emph{ComponentPrototype}s. 

\subsubsection{The \gmtoautosar Transformation.}
Although originally implemented in ATL~\cite{GMcasestudy}, the \gmtoautosar
transformation was later reimplemented in DSLTrans for the
purpose of a study where several of its properties where automatically verified~\cite{selimICGT2014}. This allowed us to increase our confidence in the correctness of the transformation. Table~\ref{tab:rulesPerLayer}
summarizes the rules in each transformation layer of the \gmtoautosar
transformation after reimplementing it in DSLTrans, and the input/output types
that are mapped/generated by each rule. 
For example, rule MapPhysNode2FiveElements in Layer 1 maps a \emph{PhysicalNode}
element in the input model to five elements in the output model (i.e.,
\emph{System, SystemMapping, SoftwareComposition, CompositionType}, and 
\emph{EcuInstance} elements).
%\mc{Explain one of the rules.}
A detailed explanation of the
mapping rules and the reimplementation of the transformation in DSLTrans can be
found in~\cite{GMcasestudy,selimICGT2014}.  DSLTrans and the notion of rule
layers is described in Sec.~\ref{subsec:dsltrans}.

\begin{table}[tb]%!h
  \centering
  \scriptsize
  %\renewcommand{\arraystretch}{1.5}
  %\includegraphics[scale=0.74]{imgs/Table_RulesPerLayer.jpg}\\[-1.5ex]

%%%  \begin{tabular}{ |p{0.8cm}|p{3.7cm}|p{1.7cm}|p{0.5\textwidth}| } %{
\begin{tabular}{ |p{0.8cm}|p{3.7cm}|p{2cm}|p{0.43\textwidth}| } %{
  %\begin{tabular}{ |p{0.5cm}|p{2.8cm}|p{1.3cm}|p{0.2\textwidth}| } %{
  % |l|l|p{1.7cm}|p{0.45\textwidth}| }
  \hline
  \textbf{Layer}  &  \textbf{Rule Name} & \textbf{Input Types} & \textbf{Output Types}\\
  \hline
  \multirow{3}{*}{1} & MapPhysNode2FiveElements & PhysicalNode, Partition,
  Module & System, SystemMapping, SoftwareComposition, CompositionType, EcuInstance\\\cline{2-4}
  
  & MapPartition & PhysicalNode, Partition, Module & SwcToEcuMapping \\
  \cline{2-4}
  & MapModule & PhysicalNode, Partition, Module &
  SwCompToEcuMapping\_component,\newline ComponentPrototype \\\hline
  
  \multirow{2}{*}{2} & MapConnPhysNode2Partition & PhysicalNode, Partition &
  SystemMapping, EcuInstance,\newline SwcToEcuMapping\\\cline{2-4}
  
  & MapConnPartition2Module & PhysicalNode, Partition, Module & CompositionType,
  ComponentPrototype,\newline SwcToEcuMapping,\newline SwCompToEcuMapping\_component \\\hline
  
  \multirow{2}{*}{3} & CreatePPortPrototype & PhysicalNode, Partition,
  Module, ExecFrame, Service & CompositionType, PPortPrototype\\\cline{2-4} &
  CreateRPortPrototype & PhysicalNode, Partition, Module, ExecFrame, Service &
  CompositionType, RPortPrototype\\\hline
  
\end{tabular}

  \caption{The rules in each layer of the \gmtoautosar transformation, and their
  input and output types.}

% \vspace{-0.3in}
\label{tab:rulesPerLayer}
\end{table}
\normalsize
% \begin{figure*}[tbh]
% \centering
% % \resizebox{0.8\textwidth}{2.0cm}{%{0.8\textwidth}{!} %2.4cm
%   \includegraphics[width=0.55\linewidth]{imgs/GMmm.jpg}\\[-2ex]
% % }
% \caption{Subset of the source GM metamodel used by our transformation
% in~\cite{GMcasestudy}.}
% \label{fig:gmMMfig}
% %\vspace{-0.6cm}
% \end{figure*}
% 
% \begin{figure*}[tbh]
% \centering
% % \resizebox{0.8\textwidth}{2.0cm}{%{0.8\textwidth}{!} %2.4cm
%   \includegraphics[width=0.65\linewidth]{imgs/AUTOSARmm.jpg}\\[-2ex]
% % }
% \caption{Subset of the target AUTOSAR metamodel used by our transformation
% in~\cite{GMcasestudy}.}
% \label{fig:gmMMfig}
% %\vspace{-0.6cm}
% \end{figure*}

